package shared.implicits

import java.io.File


import scala.util.Try

/**
 * Created by Administrator on 2019/9/12
 */
trait MyStringTool {

  implicit class MySharedString(v: String) {

    def addSuffix(suffix:String="txt"):String = {
      s"${v}.${suffix}"
    }

    def addSuffix:String = {
      addSuffix()
    }

    def fileNameSuffix: String = {
      val index = v.lastIndexOf(".")
      v.substring(index + 1)
    }

    def addFileNamePrefix(prefix: String) = {
      if (prefix.isEmpty) v else s"${prefix.toLowerCase}/${v}"
    }

    def mySplit(sep: String = "\t") = {
      v.split(sep).toList
    }

    def nonBlank = {
      v.trim.nonEmpty
    }

  }


}
